#include <stdio.h>
#include <string.h>

typedef struct{
	char id[20];
	char name[20];
	int grade1;
	int grade2;
	int grade3;
}student;

int main()
{
	int n;
	scanf("%d",&n);
	getchar();
	student students[100];
	int i;
	char temp[100];
	for(i=0;i<n;i++)
	{ 
		fgets(temp,sizeof(temp),stdin);
		char* pos=strchr(temp,'\n');
		*pos='\0';
		sscanf(temp,"%s %s %d %d %d",&students[i].id,students[i].name,&students[i].grade1,&students[i].grade2,&students[i].grade3);
	}
	int sum1=0;
	int sum2=0;
	int sum3=0;
	for(i=0;i<n;i++)
	{
		sum1+=students[i].grade1;
		sum2+=students[i].grade2;
		sum3+=students[i].grade3;
	}
	printf("%d %d %d\n",sum1/n,sum2/n,sum3/n);
	int sum0=0;
	int max=0;
	int max_idx=0;
	for(i=0;i<n;i++)
	{
		sum0=0;
		sum0+=students[i].grade1+students[i].grade2+students[i].grade3;
		if(sum0>max)
		{
			max=sum0;
			max_idx=i;
		}
	}
	printf("%s %s %d %d %d",students[max_idx].id,students[max_idx].name,students[max_idx].grade1,students[max_idx].grade2,students[max_idx].grade3);
	return 0;
}